#include "DGL3ProgramEnums.inc"

#ifdef VERTEX_SHADER

layout(location = GE_VA_Position) in vec4 aPosition;

void main()
{
	gl_Position = vec4(aPosition.xy, 0.5f, 1.0f);		
}

#endif

//---------------------------

#ifdef FRAGMENT_SHADER

uniform sampler2D uAccumTexture;
uniform sampler2D uCountTexture;

layout(location = 0) out vec4 fragColor;

void main()
{
	vec4 accum = texelFetch( uAccumTexture, ivec2(gl_FragCoord.xy), 0 );
	float n = max( 1.0, texelFetch( uCountTexture, ivec2(gl_FragCoord.xy), 0 ).r );
	// fragColor = vec4( accum.rgb / max(accum.a, 0.0001), pow(max(0.0, 1.0 - accum.a / n), n) );
	fragColor = vec4( accum.rgb / n, pow(max(0.0, 1.0 - accum.a / n), n) );
}

#endif
